/*
 * 描          述:  <描述>
 * 修  改   人:  PengQingyang
 * 修改时间:  2022年5月11日
 * <修改描述:>
 */
package com.tx.component.task.interceptor;

import java.lang.reflect.Method;
import java.util.Map;

import org.springframework.transaction.PlatformTransactionManager;

import com.tx.component.task.model.TaskDef;
import com.tx.component.task.service.TaskDefService;
import com.tx.component.task.service.TaskExecuteLogService;
import com.tx.component.task.service.TaskStatusService;
import com.tx.core.exceptions.util.AssertUtils;

/**
 * 任务执行器拦截器工厂<br/>
 * <功能详细描述>
 * 
 * @author  PengQingyang
 * @version  [版本号, 2022年5月11日]
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
public class TaskExecuteInterceptorFactory {
    
    /** 当前机器的签名 */
    private String signature;
    
    /** 任务定义业务层 */
    private TaskDefService taskDefService;
    
    /** 任务状态业务层 */
    private TaskStatusService taskStatusService;
    
    /** 任务执行日志业务层 */
    private TaskExecuteLogService taskExecuteLogService;
    
    /** transactionManager */
    private PlatformTransactionManager transactionManager;
    
    /** <默认构造函数> */
    public TaskExecuteInterceptorFactory() {
        super();
    }
    
    /** <默认构造函数> */
    public TaskExecuteInterceptorFactory(String signature,
            TaskDefService taskDefService, TaskStatusService taskStatusService,
            TaskExecuteLogService taskExecuteLogService,
            PlatformTransactionManager transactionManager) {
        super();
        this.signature = signature;
        this.taskDefService = taskDefService;
        this.taskStatusService = taskStatusService;
        this.taskExecuteLogService = taskExecuteLogService;
        this.transactionManager = transactionManager;
    }
    
    /**
     * 构建拦截器实例<br/>
     * <功能详细描述>
     * @param method2taskMap
     * @return [参数说明]
     * 
     * @return TaskExecuteInterceptor [返回类型说明]
     * @exception throws [异常类型] [异常说明]
     * @see [类、类#方法、类#成员]
     */
    public TaskExecuteInterceptor newInterceptor(
            Map<Method, TaskDef> method2taskMap) {
        AssertUtils.notEmpty(method2taskMap, "method2taskMap is empty.");
        
        TaskExecuteInterceptor interceptor = new TaskExecuteInterceptor(
                method2taskMap, signature, taskDefService, taskStatusService,
                taskExecuteLogService, transactionManager);
        return interceptor;
    }
    
    /**
     * @param 对signature进行赋值
     */
    public void setSignature(String signature) {
        this.signature = signature;
    }
    
    /**
     * @param 对taskDefService进行赋值
     */
    public void setTaskDefService(TaskDefService taskDefService) {
        this.taskDefService = taskDefService;
    }
    
    /**
     * @param 对taskStatusService进行赋值
     */
    public void setTaskStatusService(TaskStatusService taskStatusService) {
        this.taskStatusService = taskStatusService;
    }
    
    /**
     * @param 对taskExecuteLogService进行赋值
     */
    public void setTaskExecuteLogService(
            TaskExecuteLogService taskExecuteLogService) {
        this.taskExecuteLogService = taskExecuteLogService;
    }
    
    /**
     * @param 对transactionManager进行赋值
     */
    public void setTransactionManager(
            PlatformTransactionManager transactionManager) {
        this.transactionManager = transactionManager;
    }
}
